<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
    <title>微课堂 V1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="layui-anim layui-anim-up">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="welcome.html">首页</a>
        <a href="course-list.html">课程管理</a>
        <a>
          <cite>课程列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
     <div class="layui-form layui-col-md12 x-so">
          <input type="text" name="content" id="content"  placeholder="课程名或者讲师" autocomplete="off" class="layui-input">
          <button class="layui-btn" lay-filter="content" id="searchList"><i class="layui-icon">&#xe615;</i></button>
       </div>
    
	<!-- <div class="layui-btn-group courseTableTable">
	  <button class="layui-btn" data-type="getCheckData">获取选中行数据</button>
	  <button class="layui-btn" data-type="getCheckLength">获取选中数目</button>
	  <button class="layui-btn" data-type="isAll">验证是否全选</button>
	</div> -->
 
	<table class="layui-table" lay-data="{width: 918, height:500, url:'/wechat/course/search2', page:true, id:'listTable'}" lay-filter="courseTable">
	  <thead>
	    <tr>
	     <!--  <th lay-data="{type:'checkbox', fixed: 'left'}"></th> -->
	      <th lay-data="{field:'courseId', width:100, sort: true, fixed: true}">课程编号</th>
	      <th lay-data="{field:'courseName', width:140, sort: true}">课程名称</th>
	      <th lay-data="{field:'courseContent', width:250}">课程简介</th>
	      <th lay-data="{field:'type', width:80}">分类</th>
	      <th lay-data="{field:'teacher', width:80}">讲师</th>
	      <th lay-data="{field:'videotime', width:140, sort: true}">课程时长</th>
	      <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#barcourseTable'}">操作</th>
	    </tr>
	  </thead>
	</table>
    </div>
	<script type="text/html" id="barcourseTable">
  		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
 		 <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
	</script>
	               
	<script>
	layui.use('table', function(){
	  var table = layui.table;
	  //监听表格复选框选择
	  table.on('checkbox(courseTable)', function(obj){
	    console.log(obj)
	  });
	  //监听工具条
	  table.on('tool(courseTable)', function(obj){
	    var data = obj.data;
	    if(obj.event === 'del'){
	      layer.confirm('真的删除行么', function(index){
	    	  	$.ajax({
	    	  		url : '/wechat/course/delete',
	    	  		method : 'get',
	    	  		data : {
	    	  			courseId : data.courseId,
	    	  			openId : data.creater
	    	  		},
	    	  		success: function(data){
			        obj.del();
			        layer.close(index);
			        layer.msg('删除成功');
	    	  		},
	    	  		fail : function(){
	    	  			layer.msg('删除失败');
	    	  		}
	    	  	});
	      });
	    } else if(obj.event === 'edit'){
	     // layer.alert('编辑行：<br>'+ JSON.stringify(data))
	      x_admin_show('课程编辑','course-edit.html?courseId='+data.courseId,800,600)
	    }
	  });
	  
	  $("#searchList").on('click', function(){
		  table.reload('listTable', {
			  url: '/wechat/course/search2',
			  where: {
				  content : $("#content").val()
			  } //设定异步数据接口的额外参数
		  });
	  });
	  
	/*   var $ = layui.$, active = {
	    getCheckData: function(){ //获取选中数据
	      var checkStatus = table.checkStatus('listTable'),data = checkStatus.data;
	      layer.alert(JSON.stringify(data));
	    }
	    ,getCheckLength: function(){ //获取选中数目
	      var checkStatus = table.checkStatus('listTable'),data = checkStatus.data;
	      layer.msg('选中了：'+ data.length + ' 个');
	    }
	    ,isAll: function(){ //验证是否全选
	      var checkStatus = table.checkStatus('listTable');
	      layer.msg(checkStatus.isAll ? '全选': '未全选')
	    }
	  };
	  
	  $('.courseTableTable .layui-btn').on('click', function(){
	    var type = $(this).data('type');
	    active[type] ? active[type].call(this) : '';
	  }); */
	});
	</script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>
  
</html>